package me.zhengjie.dto.sqlServer;

import cn.hutool.core.date.DateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

@Entity
@Data
@Table(name="wms_task")
public class WmsTask implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "id")
    private Integer id;

    /**
     *
     */
    @Column(name = "`logical_address_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "设备类型")
    private Integer logicalAddressType;

    /**
     * 任务id
     */
    @Column(name = "`wms_task_id`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "任务id")
    private String wmsTaskId;

    /**
     * 容器编码
     */
    @Column(name = "`lpn_code`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "容器编码")
    private String lpnCode;

    /**
     * 容器类型
     */
    @Column(name = "`lpn_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "容器类型")
    private Integer lpnType;

    /**
     * 任务类型
     */
    @Column(name = "`wcs_task_type`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "任务类型")
    private Integer wcsTaskType;

    /**
     * 巷道号
     */
    @Column(name = "`aisle`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "巷道号")
    private Integer aisle;

    /**
     * 起点
     */
    @Column(name = "`from_location`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "起点")
    private String fromLocation;

    /**
     * 终点
     */
    @Column(name = "`to_location`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "终点")
    private String toLocation;

    /**
     * 优先级
     */
    @Column(name = "`level`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "优先级")
    private Integer level;

    /**
     * 状态
     */
    @Column(name = "`status`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "状态")
    private Integer status;

    /**
     * 任务描述
     */
    @Column(name = "`description`")
    @ApiModelProperty(value = "任务描述")
    private String description;

    /**
     * 创建时间
     */
    @Column(name = "`created`")
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Timestamp created;

    public void copy(WmsTask source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
